package com.zhuzi.guicollect.utils;

import org.jsoup.Connection;
import org.jsoup.Jsoup;

import java.io.IOException;

/**
 * @author MI
 * @ClassName HttpUtils.java
 * @createTime 2021年10月27日 15:45:00
 */
public class HttpUtils {
    public static String httpGet(String url) {
        try {
            /*String html = Request.Get(url)
                    .connectTimeout(3 * 1000)
                    .socketTimeout(3 * 1000)
                    .execute().returnContent().asString(StandardCharsets.UTF_8);*/
            String html = Jsoup.connect(url)
                    .header("Cookie", SysUtils.getLoginStr())
                    .method(Connection.Method.GET)
                    .execute().body();
            return html;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return "";
    }

    public static boolean isLogin() {
        Connection.Response execute = null;
        try {
            execute = Jsoup.connect(UrlConst.shouchang)
                    .header("Cookie", SysUtils.getLoginStr())
                    .followRedirects(false).execute();
            return execute.statusCode() == 200;
        } catch (IOException e) {
        }
        return false;
    }
}
